]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
closeDialog: Actually set key focus to button when grabbing key focus
authorJonas Dreßler <verdre@v0yd.nl>
Sun, 27 Oct 2019 17:58:16 +0000 (18:58 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 29 Jan 2024 23:14:24 +0000 (23:14 +0000)
When setting the key focus to `this._dialog`, the default button is not
automatically focused and no button has key focus.

Use the `initialKeyFocus` property of the dialog instead, and set focus
to the default button if the dialog is not already focused.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/786>

js/ui/closeDialog.js

index b3b8d4cf305b6942939a77288156a823c7ccd43d..a0857298ec16a6890ea3c1bca6e71f8f663742f4 100644 (file)
@@ -208,7 +208,11 @@ export const CloseDialog = GObject.registerClass({
     }
 
     vfunc_focus() {
-        if (this._dialog)
-            this._dialog.grab_key_focus();
+        if (!this._dialog)
+            return;
+
+        const keyFocus = global.stage.key_focus;
+        if (!keyFocus || !this._dialog.contains(keyFocus))
+            this._dialog.initialKeyFocus.grab_key_focus();
     }
 });